home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9616 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: confusion between putchar and printf
  5. Date: Tue, 12 Mar 96 01:06:28 GMT
  6. Organization: none
  7. Message-ID: <826592788snz@genesis.demon.co.uk>
  8. References: <4i1v2n$30o@news.azstarnet.com> <Do4GwL.Kv4@world.std.com>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <Do4GwL.Kv4@world.std.com> klanza@world.std.com "Kurt J Lanza" writes:
  15.  
  16. >># define A "hello world!"
  17.  
  18. >What did the compiler say? Something about invalid type, I
  19. >wouls suspect. You have defined A as a character pointer.
  20.  
  21. A (or rather the "hello world!" which is substitued for A) has type
  22. "array of 13 char". It is not a char *, for example sizeof(A) is 13 and
  23. is unlikely to equal sizeof(char *) on any reasonable platform.
  24.  
  25. >>       c =  A;                 (1)
  26.  
  27. Here A is in a context where a value is required (the right hand operand of
  28. = ). When you take the value of an array you get a pointer to its first
  29. element so it is true that this is attempting to assign a value with type
  30. char * to c. However A itself is not a char * and particularly not in the
  31. context of its definition.
  32.  
  33. >(1) You can't assign a character pointer to an integer.
  34.  
  35. That is indeed the problem.
  36.  
  37. -- 
  38. -----------------------------------------
  39. Lawrence Kirby | fred@genesis.demon.co.uk
  40. Wilts, England | 70734.126@compuserve.com
  41. -----------------------------------------
  42.